/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.dao.ibatis;

import model.dao.SocioDao;
import com.ibatis.sqlmap.client.SqlMapClient;
import model.bean.Socio;
import java.util.List;
import java.util.Map;
import model.common.ibatis.IbatisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

/**
 * @Archivo SocioDaoIbatis.java
 * @Fecha                @Autor   @Cambios
 * 21/01/2011 04:06:26 PM       moshiro
 */
@Repository
public class SocioDaoIbatis extends SqlMapClientDaoSupport implements SocioDao {

    @Autowired
    public SocioDaoIbatis(SqlMapClient arg) {
        setSqlMapClient(arg);
    }

    public Long agregarSocio(Socio socio) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(socio);
        return ((Long) getSqlMapClientTemplate().queryForObject("agregarSocio", parameterMap)).longValue();
    }

    public Integer modificarSocio(Socio socio) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(socio);
        return ((Integer) getSqlMapClientTemplate().update("modificarSocio", parameterMap));
    }

    public Integer eliminarSocio(Long codigo) throws DataAccessException {
        Socio socio = new Socio();
        socio.setCodigo(codigo);
        return ((Integer) getSqlMapClientTemplate().delete("eliminarSocio", socio));
    }

    public List<Socio> listarSocio(Socio socio) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(socio);
        return getSqlMapClientTemplate().queryForList("listarSocio", parameterMap);
    }

}
